<?php
/*
*
* workflow  审批流程系统-频道模型
*
* ----------------------------------------------
* 零起飞网络 - 专注于企业管理系统开发
* 以质量求生存，以服务谋发展，以信誉创品牌 !
* ----------------------------------------------
* @copyright	Copyright (C) 2017-2018 07FLY Network Technology Co,LTD All rights reserved.
* @license    For licensing, see LICENSE.html
* @author ：kfrs <goodkfrs@QQ.com> 574249366
* @version ：1.0
* @link ：http://www.07fly.xyz
*/

namespace app\workflow\controller;

/**
 * 流程节点管理-控制器
 */
class WorkflowNode extends WorkflowBase
{

	/**
	 * 流程节点列表=》模板
	 * @return mixed|string
	 */
	public function show()
	{
		$this->common_data();
		return $this->fetch('show');
	}

	/**
	 * 流程节点列表-》json数据
	 * @return
	 */
	public function show_json()
	{
		$where = [];
		$where = $this->logicWorkflowNode->getWhere($this->param);
		$orderby = $this->logicWorkflowNode->getOrderBy($this->param);
		$list = $this->logicWorkflowNode->getWorkflowNodeList($where, true, $orderby);
		return $list;
	}


	/**
	 * 流程节点添加
	 * @return mixed|string
	 */
	public function add()
	{

		IS_POST && $this->jump($this->logicWorkflowNode->workflowNodeAdd($this->param));
		$this->common_data();
		return $this->fetch('add');
	}

	/**
	 * 流程节点编辑
	 * @return mixed|string
	 */

	public function edit()
	{

		IS_POST && $this->jump($this->logicWorkflowNode->workflowNodeEdit($this->param));
		$info = $this->logicWorkflowNode->getWorkflowNodeInfo(['id' => $this->param['id']]);
		$this->assign('info', $info);
		$this->common_data();
		return $this->fetch('edit');
	}

	/**
	 * 流程节点删除
	 */
	public function del()
	{
		$where = empty($this->param['id']) ? ['id' => 0] : ['id' => $this->param['id']];
		$this->jump($this->logicWorkflowNode->workflowNodeDel($where));
	}

	/**
	 * 排序
	 */
	public function set_visible()
	{
		$this->jump($this->logicWorkflowNode->setField('WorkflowNode', $this->param));
	}

	/**
	 * 排序
	 */
	public function set_sort()
	{
		$this->jump($this->logicWorkflowNode->setField('WorkflowNode', $this->param));
	}

	/**
	 * 公共数据
	 * Author: lingqifei created by at 2020/6/15 0015
	 */
	public function common_data()
	{

		$sys_user = $this->logicSysUser->getSysUserSubList();
		$this->assign('sys_user_list', $sys_user);
		$this->assign('sys_user_id', SYS_USER_ID);

		$destribute_type_list = $this->logicWorkflowNode->getDestributeType();
		$this->assign('destribute_type_list', $destribute_type_list);

		if (!empty($this->param['workflow_id'])) {
			$this->assign('workflow_id', $this->param['workflow_id']);
		} else {
			$this->assign('workflow_id', '0');
		}

	}

}
